using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace Helpers
{
    public static class ForumSecurityHelper
    {
        public static bool CurrentUserCanViewForum(DAL.Forum forum)
        {
            DAL.User user = Managers.UserLoginManager.CurrentUser;
            if (forum == null)
            {
                return false;
            }
            else
            {
                if (user != null)
                {
                    if (user.Status == DAL.User.UserStatus.Banned)
                    {
                        return forum.MinimumRequiredStatus == DAL.User.UserStatus.Unregistered;
                    }
                    else
                    {
                        return user.HasPermissions(forum.MinimumRequiredStatus);
                    }
                }
                else
                {
                    return forum.MinimumRequiredStatus == DAL.User.UserStatus.Unregistered;
                }
            }
        }
    }
}